import { createRouter, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
      {
        path:'/',
        redirect:'/user'
      },
      {
        path:'/user',
        component:()=> import('@/views/user/UserEdit.vue'),
        meta:{
            title:"用户编辑"
        }
      },
      {
        path:'/address',
        component:()=> import('@/views/address/AddressList.vue'),
        meta:{
          title:"地址列表"
      }
      },
      {
        path:'/address/:id',
        component:()=> import('@/views/address/AddressList.vue'),
        meta:{
          title:"地址编辑"
      }
      }
  ],
})

// 在之前可以做一些判断
router.beforeEach((to,from,next)=>{
//  如果想让对面过去,必须执行next函数
next()
})
router.afterEach((to,from)=>{
  document.title =to.meta.title as string
})


export default router
